package com.ipoint.intr.smartCatalog.model.template;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;

import org.hibernate.validator.NotNull;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Role;

import com.ipoint.intr.smartCatalog.model.BaseObject;

@Entity
@Name(Template.DEFAULT_NAME)
@Role(name = Template.EDIT_TEMPLATE_NAME, scope = ScopeType.CONVERSATION)
public class Template extends BaseObject {

	public static final String DEFAULT_NAME = "template";
	public static final String EDIT_TEMPLATE_NAME = "editTemplate";

	@OneToMany(mappedBy = "template", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	private List<Attribute> attributeList;

	@NotNull
	private String name;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Attribute> getAttributeList() {
		if (attributeList == null) {
			attributeList = new ArrayList<Attribute>();
		}
		return attributeList;
	}

	public void setAttributeList(List<Attribute> attributeList) {
		this.attributeList = attributeList;
	}
}
